#ifndef THINK_THINK_RESPONSE_JSONP_H
#define THINK_THINK_RESPONSE_JSONP_H

static char* think_response_jsonp =
	"\n"
	"// +----------------------------------------------------------------------\n"
	"// | ThinkPHP [ WE CAN DO IT JUST THINK ]\n"
	"// +----------------------------------------------------------------------\n"
	"// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.\n"
	"// +----------------------------------------------------------------------\n"
	"// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )\n"
	"// +----------------------------------------------------------------------\n"
	"// | Author: liu21st <liu21st@gmail.com>\n"
	"// +----------------------------------------------------------------------\n"
	"\n"
	"namespace think\\response;\n"
	"\n"
	"use think\\Request;\n"
	"use think\\Response;\n"
	"\n"
	"class Jsonp extends Response\n"
	"{\n"
	"    // 输出参数\n"
	"    protected $options = [\n"
	"        \'var_jsonp_handler\'     => \'callback\',\n"
	"        \'default_jsonp_handler\' => \'jsonpReturn\',\n"
	"        \'json_encode_param\'     => JSON_UNESCAPED_UNICODE,\n"
	"    ];\n"
	"\n"
	"    protected $contentType = \'application/javascript\';\n"
	"\n"
	"    /**\n"
	"     * 处理数据\n"
	"     * @access protected\n"
	"     * @param mixed $data 要处理的数据\n"
	"     * @return mixed\n"
	"     * @throws \\Exception\n"
	"     */\n"
	"    protected function output($data)\n"
	"    {\n"
	"        try {\n"
	"            // 返回JSON数据格式到客户端 包含状态信息 [当url_common_param为false时是无法获取到$_GET的数据的，故使用Request来获取<xiaobo.sun@qq.com>]\n"
	"            $var_jsonp_handler = Request::instance()->param($this->options[\'var_jsonp_handler\'], \"\");\n"
	"            $handler           = !empty($var_jsonp_handler) ? $var_jsonp_handler : $this->options[\'default_jsonp_handler\'];\n"
	"\n"
	"            $data = json_encode($data, $this->options[\'json_encode_param\']);\n"
	"\n"
	"            if ($data === false) {\n"
	"                throw new \\InvalidArgumentException(json_last_error_msg());\n"
	"            }\n"
	"\n"
	"            $data = $handler . \'(\' . $data . \');\';\n"
	"            return $data;\n"
	"        } catch (\\Exception $e) {\n"
	"            if ($e->getPrevious()) {\n"
	"                throw $e->getPrevious();\n"
	"            }\n"
	"            throw $e;\n"
	"        }\n"
	"    }\n"
	"\n"
	"}\n"
	"\n"
;
#endif